
import static java.lang.System.out;

import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Collections;
import java.util.Enumeration;

public class ListNets 
{
    public static void main(String args[]) throws Exception {
        checkHosts("192.168.1");
    }

    static void showNetInfo() throws Exception{
    	Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces();
        for (NetworkInterface netint : Collections.list(nets))
            displayInterfaceInformation(netint);
    }
    static void displayInterfaceInformation(NetworkInterface netint) throws SocketException {
        out.printf("Display name: %s\n", netint.getDisplayName());
        out.printf("Name: %s\n", netint.getName());
        Enumeration<InetAddress> inetAddresses = netint.getInetAddresses();
        for (InetAddress inetAddress : Collections.list(inetAddresses)) {
            out.printf("InetAddress: %s\n", inetAddress);
        }
        out.printf("\n");
     }
    static void checkHosts(String subnet) throws Exception{
    	   int timeout=100;
    	   for (int i=1;i<254;i++){
    	       String host=subnet + "." + i;
    	       if (InetAddress.getByName(host).isReachable(timeout)){
    	           System.out.println(host + " is reachable");
    	       }
    	   }
    	}
}  